package safeCommitter.test.report;

import java.util.Collections;
import java.util.List;

import safeCommitter.model.TestType;
import safeCommitter.model.adpters.ISCTest;
import safeCommitter.test.executor.common.TestResultType;

public class SCTestResult implements Comparable<SCTestResult>,
		ISCClassMethodTestResult {

	private final String testName;
	private final TestType testType;
	private final TestResultType status;
	private final String timeElapsed;
	private final Boolean passed;
	private ISCClassMethodTestResult parent;
	private final String clazzName;
	private final String fullName;
	private final String stackTrace;

	public SCTestResult(final TestType testType, final TestResultType status,
			final String testName, final String timeElapsed,
			final String clazzName, final String fullName,
			final String stackTrace) {
		super();
		this.testName = testName;
		this.testType = testType;
		this.status = status;
		this.timeElapsed = timeElapsed;
		passed = setPassed();
		this.clazzName = clazzName;
		this.fullName = fullName;
		this.stackTrace = stackTrace;

	}

	private Boolean setPassed() {
		return status.equals(TestResultType.SUCCESS) ? Boolean.TRUE
				: Boolean.FALSE;

	}

	public String getTestName() {
		return testName;
	}

	public TestType getTestType() {
		return testType;
	}

	public TestResultType getStatus() {
		return status;
	}

	public String getTimeSpent() {
		return timeElapsed;
	}

	public Boolean getPassed() {
		return passed;
	}

	public int compareTo(final SCTestResult o) {
		return this.getTestName().compareTo(o.getTestName());
	}

	public ISCClassMethodTestResult getParent() {
		return parent;
	}

	public void setParent(final ISCClassMethodTestResult parent) {
		this.parent = parent;
	}

	public List<? extends ISCTestResult> getChildren() {
		return Collections.emptyList();
	}

	public String getPath() {
		return fullName;
	}

	public String getStackTrace() {
		return stackTrace;
	}

	@Override
	protected Object clone() throws CloneNotSupportedException {
		return super.clone();
	}

	public ISCTest getInputTest() {
		// TODO Auto-generated method stub
		return null;
	}

	public String getClassName() {
		return clazzName;
	}

	public String getDescription() {
		return testType.name() + ":" + getPath() + ":" + getTestName();
	}

}
